package user;

import book.Book;
import book.Library;

import java.time.LocalDate;
import java.util.Scanner;

public class Administrator extends User {
    Library library = new Library();
    Scanner scanner = new Scanner(System.in);


    public Administrator(String name, int ID) {
        super(name, ID);
    }

    @Override
    public int display() {
        System.out.println("管理员 " + name + "的操作菜单");
        System.out.println("1.查找图书");
        System.out.println("2.展示图书");
        System.out.println("3.退出系统");
        System.out.println("4.上架图书");
        System.out.println("5.修改图书");
        System.out.println("6.下架图书");
        System.out.println("7.统计借阅次数");
        System.out.println("8.查看最后的前K本书");
        System.out.println("9.查看库存状态");
        System.out.println("10.检查超过一年未下架的图书");

        System.out.print("请输入你的操作：");
        Scanner scanner = new Scanner(System.in);
        int choice = scanner.nextInt();

        return choice;
    }
    //展示图书
    public void displayBook(){
        library.displayBook();
    }
    //搜索图书
    public void searchBook(){
        library.searchBook();
    }
    //上架图书
    public void add(){
        System.out.print("请输入书名：");
        String bookName = scanner.nextLine();
        System.out.print("请输入作者名称：");
        String auther = scanner.nextLine();
        System.out.print("请输入书籍类型：");
        String category = scanner.nextLine();
        System.out.print("请输入出版年份：");
        int publishYear = scanner.nextInt();
        LocalDate localDate = LocalDate.now();

        Book book1 = new Book(bookName,auther,category,publishYear,localDate);

        library.add(book1);
    }
    //修改图书
    public void updataBook(){

        int pos = library.searchBookByID();
        if(pos != -1) library.updataBook(pos);

    }

    //退出系统
    public void systemExit(){
        library.systemExit();
    }

    //下架图书
    public void removeBook(){
        System.out.print("请输入需要修改的书籍ID：");
        int id = scanner.nextInt();
        int pos = library.searchBookByID();
        if(pos != -1) library.removeBook(pos);
        else System.out.println("ID" + id + "对应的书籍不存在");
    }

    //统计借阅次数
    public void borrowedCount(){
         library.borrowedCount();
    }

    //最受欢迎的图书
    public void generateBook(){
       library.generateBook();
    }

    //查看库存状态
    public void checkInventoryStatus(){
        library.checkInventoryStatus();
    };

    //检查上架一年为下架的图书
    public void checkRemoveBook(){
        library.checkRemoveBook();
    }
}
